<?php 
	class UserController extends Controller
	{
		private $model = null;
		public function __construct()
		{
			parent::__construct();
			$this->model = new Model('user');

		}

		public function index()
		{
			$data = $this->model->order('id desc')->select();
			$this->assign('title','用户列表');
			$this->assign('list',$data);
			$this->display('User/index.html');
		}

		public function del()
		{
			if($this->model->del($_GET['id'])){
				echo '1';
			}else{
				echo '0';
			}
		}

		public function add()
		{
			$this->assign('title','用户添加');
			$this->display('User/add.html');
		}

		public function insert()
		{
			if($this->model->add()){
				$this->redirect('添加成功','./index.php?c=User');
			}else{
				$this->redirect('添加失败','./index.php?c=User');
			}
		}

		public function edit()
		{
			$data = $this->model->find($_GET['id']);
			$this->assign('title','编辑用户');
			$this->assign('data',$data);
			$this->display('User/edit.html');
		}

		public function update()
		{
			if($this->model->update()){
				$this->redirect('恭喜您修改成功	','./index.php?c=User&a=index');
			}else{
				// $this->redirect('更新失败');
				echo "更新失败";
			}
		}
	}
 ?>